<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>ricc</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : April 1993</div>
    <p>
      <b>ricc</b> -  Riccati equation</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>[X,RCOND,FERR]=ricc(A,B,C,"cont""method")  </tt>
      </dd>
      <dd>
        <tt>[X,RCOND,FERR]=ricc(F,G,H,"disc","method")  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>A,B,C</b>
        </tt>: real matrices of appropriate dimensions</li>
      <li>
        <tt>
          <b>F,G,H</b>
        </tt>: real matrices of appropriate dimensions</li>
      <li>
        <tt>
          <b>X</b>
        </tt>: real matrix</li>
      <li>
        <tt>
          <b>"cont","disc"'  </b>
        </tt>: imposed string (flag for continuous or discrete)</li>
      <li>
        <tt>
          <b>method</b>
        </tt>: 'schr' or 'sign' for continuous-time systems and 'schr' or 'invf' for discrete-tyme systems</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    Riccati solver.</p>
    <p>
    Continuous time:</p>
    <pre>

  X=ricc(A,B,C,'cont')
   
    </pre>
    <p>
    gives a solution to the continuous time ARE</p>
    <pre>

  A'*X+X*A-X*B*X+C=0 .
   
    </pre>
    <p>
      <tt>
        <b>B</b>
      </tt> and <tt>
        <b>C</b>
      </tt> are assumed to be nonnegative definite.
    <tt>
        <b>(A,G)</b>
      </tt> is assumed to be stabilizable with <tt>
        <b>G*G'</b>
      </tt> a full rank
    factorization of <tt>
        <b>B</b>
      </tt>.</p>
    <p>
      <tt>
        <b>(A,H)</b>
      </tt> is assumed to be detectable with <tt>
        <b>H*H'</b>
      </tt> a full rank
    factorization of <tt>
        <b>C</b>
      </tt>.</p>
    <p>
    Discrete time:</p>
    <pre>

  X=ricc(F,G,H,'disc')
   
    </pre>
    <p>
    gives a solution  to the discrete time ARE</p>
    <pre>

  X=F'*X*F-F'*X*G1*((G2+G1'*X*G1)^-1)*G1'*X*F+H
   
    </pre>
    <p>
      <tt>
        <b>F</b>
      </tt> is assumed invertible and   <tt>
        <b>G = G1*inv(G2)*G1'</b>
      </tt>.</p>
    <p>
    One  assumes  <tt>
        <b>(F,G1)</b>
      </tt> stabilizable and <tt>
        <b>(C,F)</b>
      </tt> detectable
    with <tt>
        <b>C'*C</b>
      </tt> full rank factorization of <tt>
        <b>H</b>
      </tt>. Use preferably
    <tt>
        <b>ric_desc</b>
      </tt>.</p>
    <p>
    C, D are symmetric .It is assumed that the matrices A, C and D are such that the corresponding matrix pencil has N eigenvalues with moduli less than one.</p>
    <p>
    Error bound on the solution and a condition estimate are also provided.
    It is assumed that the matrices A, C and D are such that the
    corresponding Hamiltonian matrix has N eigenvalues with negative real parts.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

//Standard formulas to compute Riccati solutions
A=rand(3,3);B=rand(3,2);C=rand(3,3);C=C*C';R=rand(2,2);R=R*R'+eye();
B=B*inv(R)*B';
X=ricc(A,B,C,'cont');
norm(A'*X+X*A-X*B*X+C,1)
H=[A -B;-C -A'];
[T,d]=schur(eye(H),H,'cont');T=T(:,1:d);
X1=T(4:6,:)/T(1:3,:);
norm(X1-X,1)
[T,d]=schur(H,'cont');T=T(:,1:d);
X2=T(4:6,:)/T(1:3,:);
norm(X2-X,1)
//       Discrete time case
F=A;B=rand(3,2);G1=B;G2=R;G=G1/G2*G1';H=C;
X=ricc(F,G,H,'disc');
norm(F'*X*F-(F'*X*G1/(G2+G1'*X*G1))*(G1'*X*F)+H-X)
H1=[eye(3,3) G;zeros(3,3) F'];
H2=[F zeros(3,3);-H eye(3,3)];
[T,d]=schur(H2,H1,'disc');T=T(:,1:d);X1=T(4:6,:)/T(1:3,:);
norm(X1-X,1)
Fi=inv(F);
Hami=[Fi Fi*G;H*Fi F'+H*Fi*G];
[T,d]=schur(Hami,'d');T=T(:,1:d);
Fit=inv(F');
Ham=[F+G*Fit*H -G*Fit;-Fit*H Fit];
[T,d]=schur(Ham,'d');T=T(:,1:d);X2=T(4:6,:)/T(1:3,:);
norm(X2-X,1)
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="../robust/riccati.htm">
        <tt>
          <b>riccati</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="../robust/ric_desc.htm">
        <tt>
          <b>ric_desc</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="../linear/schur.htm">
        <tt>
          <b>schur</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Author</font>
    </h3>
    <p>
 P. Petkov
</p>
    <h3>
      <font color="blue">Used Function</font>
    </h3>
    <p>See SCIDIR/routines/control/riccpack&gt;</p>
  </body>
</html>
